
/**
 * 主键注解
 * @return 
 */ 
export function PrimaryKey() {
	return function (target : any, propertyKey : string) {
		if (!target.hasOwnProperty('metadata')) {
			target['metadata'] = {};
		}
		target['metadata'][propertyKey] = {
			...(target['metadata'][propertyKey] || {}),
			primaryKey: true
		};
	};
}

/**
 * 非空注解
 * @return 
 */ 
export function NotNull() {
	return function (target : any, propertyKey : string) {
		if (!target.hasOwnProperty('metadata')) {
			target['metadata'] = {};
		}
		target['metadata'][propertyKey] = {
			...(target['metadata'][propertyKey] || {}),
			notNull: true
		};
	};
}
/**
 * 数据类型注解  @FieldType({ field: 'name', type: 'text', length: 255 })
 * @param {string} field 字段名称
 * @param {string} type 数据类型
 * @param {number} length 长度
 * @return 
 */ 
export function FieldType(field : string, type : string, length ?: number) {
	return function (target : any, propertyKey : string) {
		if (!target.hasOwnProperty('metadata')) {
			target['metadata'] = {};
		}
		target['metadata'][propertyKey] = {
			...(target['metadata'][propertyKey] || {}),
			field: field,
			type: type,
			length: length,
		};
	};
}